<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>后台管理系统</title>
	    <meta name="author" content="BaiYY"/>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	    <meta name="renderer" content="webkit">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap-datetimepicker.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap-datetimepicker.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
	</head>
		<body>
			
			<!--右边侧栏开始-->
			<div class="right-sidebar" style="max-width: 1200px;">
				<ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist" id="listTab">
					<li role="presentation"><a href="initSet.html">{:L(GAME_SETTING_INIT)}</a></li>
					<li role="presentation" id="invited"><a href="activityInvite.html">{:L(GAME_SETTING_INVITE)}</a></li>
					<li role="presentation" id="roomd" class="active"><a href="activityCreateRoom.html">{:L(GAME_SETTING_ROOM)}</a></li>
					<li role="presentation" id="advd"><a href="advSet.html">{:L(GAME_SETTING_ADV)}</a></li>
					<li role="presentation" id="wheeld"><a href="luckWheel.html">{:L(GAME_SERRING_WHEEL)}</a></li>
				</ul>
			
					<div class="alert alert-info" role="alert">设置某时间段内创建房间消耗{:L(GAME_RESOURCE)}的比例</div>

				<div class="row">
					<div class="col-md-12">
						<div class="input-group">
							<span class="input-group-addon">开始时间</span>
							<input type="datetime" class="form-control form_datetime" name="start_time" id="start_time" data-date-format="yyyy-mm-dd hh:ii:ss" value="{$setting.startTime}" >
						</div>
			
						<div class="input-group">
							<span class="input-group-addon">结束时间</span>
							<input type="datetime" class="form-control form_datetime" name="start_time" id="end_time" data-date-format="yyyy-mm-dd hh:ii:ss" value="{$setting.endTime}" >
						</div>
			
						<div class="input-group">
							<span class="input-group-addon">消耗比例</span>
							<input class="form-control" type="number" name="rate" id="rate"  value="{$setting.rate}" />
							<span class="input-group-addon">%</span>
						</div>
						<p></p>
			
						<button type="submit" class="btn btn-primary center-block" id="submit">设置</button>
					</div>
				</div>
			</div>
			<script type="text/javascript">
				$(function () {
                    var invited = $.trim($("#invited").text());
                    var roomd = $.trim($("#roomd").text());
                    var advd = $.trim($("#advd").text());
                    var wheeld = $.trim($("#wheeld").text());

                    if(invited == '' || invited == 'GAME_SETTING_INVITE') {
                        $("#invited").hide();
                    }
                    if(roomd == '' || roomd == 'GAME_SETTING_ROOM') {
                        $("#roomd").hide();
                    }
                    if(advd == '' || advd == 'GAME_SETTING_ADV') {
                        $("#advd").hide();
                    }

                    if(wheeld == '' || wheeld == 'GAME_SERRING_WHEEL') {
                        $("#wheeld").hide();
                    }
                });
				$(".form_datetime").datetimepicker({
					language: 'zh-CN',
					autoclose: 1,
					todayHighlight: 1,
					weekStart: 1,
					startDate: 0
				});
				$(function(){
					$("#submit").on("click",function(){
						var start_time = $.trim($("#start_time").val());
						var end_time = $.trim($("#end_time").val());
						var rate = $.trim($('#rate').val());
						
						if(rate == '' || Number(rate) < 0) {
							alert("输入值错误");
               				return false;
						}
						var url = "{:U('Admin/Main/activityCreateRoomSave')}";
						$.ajax({
							type:"post",
							url:url,
							dataType:"json",
							data:{'rate':rate,"start_time":start_time,"end_time":end_time},
							success:function(data) {
								if(data == 'success') {
									alert("设置成功！");
									window.location.href="{:U('Admin/Main/activityCreateRoom')}";
								}else if(data == 'error'){
									alert('设置失败!');
								}
							}
						});
					});
				});
			</script>
		</body>
	</html>
